package server.main.config.mybatisplus;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @auther MingHsZzz
 * @Date 2022/10/4  15:59
 * @project main
 * @description
 */
@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
   @Override
   public void insertFill(MetaObject metaObject) {


      this.setFieldValByName("gmtCreate",new Date(),metaObject);
      this.setFieldValByName("gmtModified",new Date(),metaObject);
   }

   @Override
   public void updateFill(MetaObject metaObject) {
      this.setFieldValByName("gmtModified",new Date(),metaObject);
   }
}
